<?php
require_once INC_DEFINES;
define ('FONT', 'calibri.ttf');

if (!isset ($x) || empty ($x) || !isset ($y) || empty ($y)) {
    notify ('No data to load');
    exit ();
}
$folder = dirname (__FILE__);
include realpath ("$folder/../class/pData.class.php");
include realpath ("$folder/../class/pDraw.class.php");
include realpath ("$folder/../class/pPie.class.php");
include realpath ("$folder/../class/pImage.class.php");

/* Create and populate the pData object */
$MyData = new pData();
$MyData->addPoints ($y, "ScoreA");
$MyData->setSerieDescription ("ScoreA", "Application A");

/* Define the absissa serie */
$MyData->addPoints ($x, "Labels");
$MyData->setAbscissa ("Labels");

/* Create the pChart object */
$myPicture = new pImage (IMG_WIDTH, IMG_HEIGHT, $MyData, TRUE);

/* Set the default font properties */
$myPicture->setFontProperties (array ("FontName" => "$folder/../fonts/" . FONT, "FontSize" => 10, "R" => 80, "G" => 80, "B" => 80));

/* Create the pPie object */
$PieChart = new pPie ($myPicture, $MyData);

/* Enable shadow computing */
$myPicture->setShadow (TRUE, array ("X" => 3, "Y" => 3, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 10));

/* Draw a splitted pie chart */
$PieChart->draw3DPie (120, 90, array ("Radius" => 100, "DataGapAngle" => 12, "DataGapRadius" => 10, "Border" => TRUE));

/* Write the legend box */
$myPicture->setFontProperties (array ("FontName" => "$folder/../fonts/" . FONT, "FontSize" => 14, "R" => 0, "G" => 0, "B" => 0));
$PieChart->drawPieLegend (300, 15, array ("Style" => LEGEND_NOBORDER, "Mode" => LEGEND_VERTICAL));

/* Render the picture (choose the best way) */
$myPicture->stroke ();
?>
